HSetVol
HSetVol Select a default default volume/directory (HFS only) #include <Files.h> File Manager (PBxxx)
OsErr HSetVol( volName, vRefNum, dirID ); Str255 volName; partial or full pathname to set default directory to short vRefNum; reference number of volume to set default to long dirID; directory ID of volume to set default to
Apple does not recommend using HSetVol or PBSetVol. See the notes below for details.
HSetVol is used to select a default volume. The File Manager will use these defaults in future calls in which you specify no volume name and a volume
reference number of 0.
noErr (0) No error
nsvErr (-35) No default volume
Notes: You can specify the new default by any of the following options:
• A full or partial pathname (ends in a colon). Put the address of the
pascal-style string in ioNamePtr.
• A volume number or a working directory number in ioVRefNum If you use
a WD ref, it will affect how PBGetVol works.
• A directory number in ioWDDirID (as obtained via PBOpenWD).
See SetVol for an example showing usage of various ways to set a default volume and open a file.
HSetVol lets you specify a WDRefNum for the ioVRefNum in addition to a paritial pathname in ioNamePtr. HSetVol will start at the specified working directory and use the paritial pathname to determine the final
directory. This directory might not correspond to an already existing
working directory, so the File Manager cannot refer to this directory with a
WDRefNum. Instead it must use the actual volume refNum and the dirID
number (which is assigned when the directory is created, and does not
change). This all means that if you call HSetVol, the File Manager stores the actual volume refNum as the default volume, and the default dirID
separately. This will happen on all calls to HSetVol. Subsequent calls to GetVol or PBGetVol or HGetVol will return only the volume refNum in the ioVRefNum field of the parameter block. If any code tries to use the
refNum returned by GetVol or HGetVol, it will be accessing the root of the volume, and not the current default directory as expected. This can be
disastrous for desk accessories because they don't know that your code has
called HSetVol or PBGetVol and they don't get what they expect if they call Because of these problems, Apple does not recommend using HSetVol or PBSetVol.